$(function(){
   $("#menulistb").click(function(){
        if( $("#menutree").css("display")=='none' ) {
            $("#menutree").css("display","");
        }else{
            $("#menutree").css("display","none");
        }
      });
    
    var zTreeObj = $.fn.zTree.init($("#tree_panel"), setting, zNodes);
   
    var parentId = $("#parentId").attr("value");
    if(parentId!=null){
    	  var nodes = zTreeObj.getNodeByParam("id",parentId);
    	  if(nodes!=null){ 
    	       $("#"+nodes.tId+"_a").click();
    	  }
    }
	$("#saveSetting").click(function(){
		this.disabled="disabled";
		var $menuName = $("[name='menuName']");
		if(isEmpty($menuName.val())){
			layer.tips("菜单名称不能空",$menuName.get(0));
			$menuName.focus();
			this.disabled="";
			return false;
		}
		var $menuOrder=$("[name='menuOrder']");
		if(isEmpty($menuOrder.val())){
			layer.tips("菜单排序不能空",$menuOrder.get(0));
			$menuOrder.focus();
			this.disabled="";
			return false;
		}
		$("form").submit();
	});
	$("select[name='menuIcon']").on("click",function(){
		var $this=$(this);
		$this.next().html('<b class="'+$this.val()+'"></b>'+$this.val());
	});
});
function isEmpty(val){
	return (null==val || ""==val.replace("\\s",""));
}